package repository

import (
	"context"
	"shop_srvs/user_srv/service/cache"
)

var (
	ErrCodeSendTooMany   = cache.ErrCodeSendTooMany
	ErrCodeVarifyTooMany = cache.ErrCodeVarifyTooMany
)

type CodeRepository struct {
	cache *cache.RedisCodeCache
}

func NewCodeRepository(c *cache.RedisCodeCache) *CodeRepository {
	return &CodeRepository{cache: c}
}

// 包装cache.CodeCache
func (repo *CodeRepository) Store(ctx context.Context, biz, phone, code string) error {
	return repo.cache.Set(ctx, biz, phone, code)
}
func (repo *CodeRepository) Verify(ctx context.Context, biz, phone, code string) (bool, error) {
	return repo.cache.Varify(ctx, biz, phone, code)
}
